package com.piggy.logi.sys.controller;

import com.piggy.common.core.domain.R;
import com.piggy.common.core.web.controller.BaseController;
import com.piggy.common.log.annotation.Log;
import com.piggy.common.log.annotation.LogiLog;
import com.piggy.common.log.enums.BusinessType;
import com.piggy.common.satoken.utils.SecurityUtils;
import com.piggy.logi.sys.bo.LogiSysOrderSetEditBo;
import com.piggy.logi.sys.service.ILogiSysOrderSetService;
import com.piggy.logi.sys.vo.LogiSysOrderSetVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 系统设置运单设置Controller
 */
@Api(value = "系统设置运单设置控制器", tags = {"系统设置运单设置"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/logi/sysOrderSet")
public class LogiSysOrderSetController extends BaseController {

    private final ILogiSysOrderSetService logiSysOrderSetService;


    @ApiOperation("获取系统设置运单设置详细信息")
    //@SaCheckPermission("@ss.hasPermi('sys:orderSet:query')")
    @GetMapping()
    public R<LogiSysOrderSetVo> getInfo() {
        return R.ok(logiSysOrderSetService.queryById(SecurityUtils.getDeptId()));
    }

    @ApiOperation("新增或修改系统设置运单设置")
    //@SaCheckPermission("@ss.hasPermi('sys:orderSet:add')")
    @LogiLog(title = "承运商司机信息", businessType = BusinessType.UPDATE)
    @PostMapping("insertOrUpdate")
    public R<Integer> insertOrUpdate(@Validated @RequestBody LogiSysOrderSetEditBo bo) {
        return R.ok(logiSysOrderSetService.insertOrUpdate(bo) ? 1 : 0);
    }
}
